package com.eat.mapper;

import com.eat.entity.SetmealDish;
import com.eat.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 根据id查询套餐菜品
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getDishById(Long id);

    /**
     * 根据套餐id删除套餐菜品
     * @param id
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteBySetmealId(Long id);

    /**
     * 添加套餐菜品
     * @param setmealDish
     */
    @Insert("insert into setmeal_dish(setmeal_id,dish_id,name,price,copies) " +
            "values (#{setmealId},#{dishId},#{name},#{price},#{copies})")
    void saveSetmealDish(SetmealDish setmealDish);

    void deleteBySetmealIds(List<Long> ids);

    List<DishItemVO> getSetmealDishById(Long id);
}
